package com.example.weight.greenSeasons.compost;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.weight.R;
import com.hjq.bar.OnTitleBarListener;
import com.hjq.bar.TitleBar;

import net.cachapa.expandablelayout.ExpandableLayout;

import java.util.Calendar;

public class duifeiyuebaoyang extends AppCompatActivity {
    private String factory;
    private ExpandableLayout zhoubaoyang;
    private Button zhouButton;
    private ExpandableLayout yuebaoyang;
    private Button yueButton;

    private TextView dateEdit;

    private TitleBar titleBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_duifeiyuebaoyang);
        zhoubaoyang=findViewById(R.id.expandable_zhou);
        zhouButton=findViewById(R.id.button16);
        yuebaoyang=findViewById(R.id.expandable_yue);
        yueButton=findViewById(R.id.button17);
        dateEdit=findViewById(R.id.compost_editDate);
        Calendar calendar=Calendar.getInstance();
        Integer year = calendar.get(Calendar.YEAR);
        Integer month = calendar.get(Calendar.MONTH)+1; //第一个月从0开始，所以得到月份＋1
        Integer day = calendar.get(calendar.DAY_OF_MONTH);
        Integer hour24 = calendar.get(calendar.HOUR_OF_DAY);
        Integer minute = calendar.get(calendar.MINUTE);
        Intent previousIntent = getIntent();
        factory = previousIntent.getStringExtra("factory");
        dateEdit.setText(year+"-"+month+"-"+day);
        titleBar=findViewById(R.id.titleBar);
        titleBar.setOnTitleBarListener(new OnTitleBarListener() {

            @Override
            public void onLeftClick(View v) {
                duifeiyuebaoyang.this.finish();
            }

            @Override
            public void onTitleClick(View v) {

            }

            @Override
            public void onRightClick(View v) {

            }


        });
    }
    public void showzhou(View view) {
        if (zhoubaoyang.isExpanded()){
            zhouButton.setText("+ 周保养");
        }else{
            zhouButton.setText("- 周保养");
        }

        zhoubaoyang.toggle();
    }

    public void showyue(View view) {
        if (yuebaoyang.isExpanded()){
            yueButton.setText("+ 月保养");
        }else{
            yueButton.setText("- 月保养");
        }

        yuebaoyang.toggle();
    }
}